package com.example.haoqisystem.controller;

import com.example.haoqisystem.entity.TrainningPlan;
import com.example.haoqisystem.request.CreateTrainningPlanRequest;
import com.example.haoqisystem.request.QueryTrainningPlanListRequest;
import com.example.haoqisystem.request.UpdateTrainningPlanRequest;
import com.example.haoqisystem.response.BaseResponse;
import com.example.haoqisystem.response.PageResult;
import com.example.haoqisystem.service.TrainPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "培训计划api")
@RestController
@RequestMapping("/trainningPlan")
@RequiredArgsConstructor(onConstructor_ ={@Autowired} )
public class TrainningPlanController {
    private final TrainPlanService trainPlanService;

    @ApiOperation(value = "新增培训计划")
    @PostMapping("/add")
    public BaseResponse<TrainningPlan> add(@RequestBody CreateTrainningPlanRequest request){
        return trainPlanService.add(request);
    }

    @ApiOperation(value = "查询培训计划详情")
    @GetMapping("/detail")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "培训计划id",required = true)
    })
    public BaseResponse<TrainningPlan> detail(Long id){
        return trainPlanService.detail(id);
    }

    @ApiOperation(value = "更新培训计划")
    @PutMapping("/update")
    public BaseResponse<TrainningPlan> update(@RequestBody UpdateTrainningPlanRequest request){
        return trainPlanService.update(request);
    }

    @ApiOperation(value = "删除培训计划")
    @GetMapping("/delete")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "培训计划id",required = true)
    })
    public BaseResponse<String> delete(Long id){
        return trainPlanService.delete(id);
    }

    @ApiOperation(value = "分页查询培训计划列表")
    @PostMapping("/queryPageList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deleted",value = "逻辑删除（0 1）",required = true,dataType = "Boolean"),
            @ApiImplicitParam(name = "pageNum",value = "页数",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页大小",required = true)
    })
    public BaseResponse<PageResult<TrainningPlan>> queryList(QueryTrainningPlanListRequest request){
        return trainPlanService.queryList(request);
    }

    @ApiOperation(value = "培训计划列表")
    @GetMapping("/queryList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deleted",value = "逻辑删除(true,false)",required = true,dataType = "Boolean"),
            @ApiImplicitParam(name = "lectureName",value = "课程名(模糊查询)"),
            @ApiImplicitParam(name = "isGenerateLecture",value = "是否已经生成课程"),
            @ApiImplicitParam(name = "id",value = "id",dataType = "Long")
    })
    public BaseResponse<List<TrainningPlan>> queryList1(boolean deleted,String lectureName
            ,Boolean isGenerateLecture,Long id){
        return trainPlanService.queryList1(deleted,lectureName,isGenerateLecture,id);
    }
}
